package com.example.testapp

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.activity.viewModels
import androidx.lifecycle.Observer
import com.qiantoon.networkdsl.base.BaseNetworkApi
import com.qiantoon.networkdsl.http.Request
import com.qiantoon.networkdsl.support.BasePreferences
import com.qiantoon.networkdsl.support.PreferencesUtil

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        val viewModel: MainViewModel by viewModels()

        PreferencesUtil.init(application)
        BaseNetworkApi.init(NetworkRequiredInfo(application))
        Request.onSystemMaintenance {

        }

        Request.onTokenInvalid {

        }

        Request.networkOp = NetWorkOp()

        viewModel.login()

        viewModel.loginState.observe(this, Observer {
            if(it){
                viewModel.queryMyHealthyCircleList()
            }
        })


    }
}